/*
 * @Author: your name
 * @Date: 2024-04-06 16:01:24
 * @LastEditTime: 2024-04-06 16:06:27
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\541.反转字符串-ii.cpp
 */
/*
 * @lc app=leetcode.cn id=541 lang=cpp
 *
 * [541] 反转字符串 II
 */

// @lc code=start
class Solution {
public:
    string reverseStr(string s, int k) {
        for(int i = 0; i< s.size(); i+=(2*k)){
            if(i+k < s.size()){
                reverse(s.begin()+i,s.begin()+i+k);
            }
            else{
                reverse(s.begin()+i, s.end());
            }
        }
        return s;
    }
};
// @lc code=end

